<?php
/**
 * Created by yb.
 * Author: 1021948372@qq.com
 * Date: 2020/7/7 07:07
 */
namespace app\common\model;

use think\Model;
use app\common\lib\BackendPage;

class Base extends Model{

    /**
     * 分页数据获取
     * @param string $field
     * @param array $map
     * @param string $order
     * @return array
     */
    public function getPageListData($field = "*", $map = array(), $order = ""){
        $result = array(
            'dataList' => array(),
            'count' => 0,
            'curr' => input('page',1),
            'limit' => input('limit',10),
        );
        $count = $this->where($map)->count();
        $result['count'] = $count;
        if($count > 0){
            $offset = ($result['curr'] - 1) * $result['limit'];
            $dataList = $this->field($field)->where($map)->limit($offset, $result['limit'])->order($order)->select();
            $result['dataList'] = $dataList;
        }
        return $result;
    }

}